<script>

/**
 * Orders Component
 */
export default {
  data() {
    return {
      ordersData: [
        {
          title: "市住房和城乡建设局局长谢进才开展春节前燃气与供热安全生产督导检查",
          source: "徐州市住房和城乡建设局",
          emotion: "积极",
          industry: "房产行业",
          cause: "乡村振兴",
          article: "社会",
          time: "12分钟前"
        }
      ],
      totalRows: 100,
      currentPage: 1,
      perPage: 10,
      fields: [
        { key: "title", label: "标题" },
        { key: "source", label: "来源" },
        { key: "emotion", label: "情感标签" },
        { key: "cause", label: "事件标签" },
        { key: "article", label: "文章分类" },
        { key: "industry", label: "行业标签" },
        { key: "time", label: "时间" }
      ],
    };
  },
  watch: {
    "currentPage": {
      handler(){
        console.log("触发更新");
      }
    }
  },
  methods: {
    /**
     * Search the table data with search input
     */
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
  }
};
</script>

<template>
  <div>
    <!-- 搜索 -->
      <div class="search-box">
        <div class="position-relative search">
          <input type="text" class="form-control" placeholder="请输入关键字" />
          <i class="mdi mdi-magnify search-icon"></i>
        </div>
      </div>
      <div class="allNum">
        <div class="searchNum">为您检索到<span>5,000+</span>条媒体文章信息</div>
      </div>
      <div class="table-responsive">
        <b-table
          class="table-centered"
          :items="ordersData"
          :fields="fields"
          responsive="sm"
          :per-page="perPage"
          :current-page="1"
          thead-class="thead-light"
          @filtered="onFiltered"
        >
          <template v-slot:cell(title)="row">
            <a style="font-size:.9rem;" href="/#/datahouse/weMediaArticleDetail">{{row.value}}</a>
          </template>
          <template v-slot:cell(emotion)="row">
            <div v-if="row.value=='积极'" class="badge font-size-12 badge-soft-success">{{ row.value}}</div>
            <div v-if="row.value=='中性'" class="badge font-size-12 badge-soft-warning">{{ row.value}}</div>
            <div v-if="row.value=='消极'" class="badge font-size-12 badge-soft-danger">{{ row.value}}</div>
          </template>
          <template v-slot:cell(industry)="row">
            <div class="badge font-size-12 badge-soft-primary">{{ row.value}}</div>
          </template>
        </b-table>
      </div>
      <div class="row">
        <div class="col">
          <div class="dataTables_paginate paging_simple_numbers float-right">
            <ul class="pagination pagination-rounded mb-0">
              <!-- pagination -->
              <b-pagination v-model="currentPage" :total-rows="totalRows" :per-page="perPage"></b-pagination>
            </ul>
          </div>
        </div>
      </div>
  </div>
</template>
<style lang="scss" scoped>
.search {
  max-width: 300px;
  margin-bottom: 20px;
}
.border-radius{
  border-radius: 0px;
  border-bottom-left-radius: 30px;
  border-top-left-radius: 30px;
}
.right-dropdown{
  ::v-deep .btn{
    font-size: 0;
    border-radius: 0px;
    padding: 0.47rem 0.5rem;
    border-bottom-right-radius: 30px;
    border-top-right-radius: 30px;
    i{
      font-size: 0.9rem;
      vertical-align: middle;
    }
  }
}
.table-centered{
  ::v-deep thead,::v-deep tbody{
    tr{
      th:last-child,td:last-child{
        text-align: right;
      }
    }
  }
  ::v-deep tbody{
    tr{
      td{
        font-size: 13px;
      }
    }
  }
}
.allNum{
  padding-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.searchNum{
  span{
    font-size: 1rem;
    color: #3444c1;
    margin: 0 4px;
    font-weight: 600;
  }
}
.butn{
  ::v-deep .btn{
    background-color: #252b3b;
    border-color: #252b3b;
    border-radius: 30px;
    display: flex;
    align-items: center;
  }
  ::v-deep .btn-secondary.focus {
    box-shadow: 0 0 0 0.15rem rgb(37 40 58 / 50%);
  }
}
</style>

